<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>axios使用</title>
    <link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css"
        rel="stylesheet">
    <script crossorigin="anonymous" src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
</head>

<body>
    <div class="container">
        <h2 class="page-header">对象独立方法使用</h2>
        <button class="btn btn-primary" onclick="sendGET()"> 发送 GET 请求 </button>
        <button class="btn btn-warning" onclick="sendPOST()"> 发送POST请求 </button>
        <button class="btn btn-success" onclick="sendPUT()"> 发送 PUT 请求 </button>
        <button class="btn btn-info" onclick="sendPatch()"> 发送 PATCH 请求 </button>
        <button class="btn btn-danger" onclick="sendDELETE()"> 发送 DELETE 请求 </button>
    </div>
    <script>
        function sendGET() {
            // get请求语法： axios.get(url[,配置对象])
            axios.get('http://zyx.com:8080/server', { params: { a: 1, b: 2 } });
        }
        function sendDELETE() {
            // delete 请求语法： axios.get(url[,配置对象])
            axios.delete('http://zyx.com:8080/server', { params: { a: 11, b: 22 } });
        }
        function sendPOST(){
            // post语法： axios.post(url,data[,配置对象])
            axios.post('http://zyx.com:8080/server',{username:'yuonly',age:100},{headers:{zzz:1}});
        }

        function sendPUT(){
            // put 语法： axios.put(url,data[,配置对象])
            axios.put('http://zyx.com:8080/server',{name:'atguigu',age:99},{headers:{yyy:2}})
        }

        function sendPatch(){
            // patch 语法： axios.patch(url,data[,配置对象])
            axios.patch('http://zyx.com:8080/server',{name123:'atguigu1111',age:199},{headers:{yyy123:2}})
        }

    </script>
</body>

</html>